#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/10/22 10:25
# @Author  : 王凯
# @File    : __init__.py.py
# @Project : scrapy_spider
import time

from loguru import logger

from components.config import WFQ_SOURCE_MYSQL_CONFIG
from utils.db.mysqldb import MysqlDB

TABLE_NET_PDD_SHOP_INFO = "net_pdd_shop_info_task"

if __name__ == '__main__':
    _to_db = MysqlDB(
        ip=WFQ_SOURCE_MYSQL_CONFIG["MYSQL_IP"],
        port=WFQ_SOURCE_MYSQL_CONFIG["MYSQL_PORT"],
        db=WFQ_SOURCE_MYSQL_CONFIG["MYSQL_DB"],
        user_name=WFQ_SOURCE_MYSQL_CONFIG["MYSQL_USER_NAME"],
        user_pass=WFQ_SOURCE_MYSQL_CONFIG["MYSQL_USER_PASS"],
    )
    sql = """
    update
    net_pdd_shop_info
    set flag = 2 , last_crawler_time = null
    where is_all = 1
      and shop_name = ''
      and flag != -1 limit 10;
    """
    while True:
        res = _to_db.execute(sql)
        if res:
            logger.info("更新成功")
            time.sleep(60)
        else:
            break
